<base href="<?php echo base_url();?>" />
<table id="fragen">
	<thead>
	    <tr>
	      <th>ID</th>
	      <th class="filter-select" data-placeholder="Wähle ein Fragenart">Fragenart</th>
	      <th class="filter-select" data-placeholder="Wähle ein Fach" data-value=<?php echo $klausuren['Fach'];?> >Fach</th>
	      <th>Frage</th>
	      <!--<th>Antwort 1</th>
	      <th>Antwort 2</th>
	      <th>Antwort 3</th>
	      <th>Antwort 4</th>
	      <th>Antwort 5</th>
	      <th>Lösung 1</th>
	      <th>Lösung 2</th>
	      <th>Lösung 3</th>-->
	      <th>Antworten</th>
	      <th>Lösungen</th>
	      <th>Punkte</th>
	      <th class="filter-false remove sorter-false">Bearbeiten</th>      
	    </tr>
  	</thead>
	<tbody > 
		<?php foreach ($fragen as $row): ?>
		<tr>
	        <td><?php echo $row['ID'];?></td>
	        <td><?php echo $row['Fragenart'];?></td>
	        <td><?php echo $row['Fach'];?></td>
	        <td><?php echo $row['Frage'];?></td>
	        <!--<td><?php echo $row['Antwort1'];?></td>
	        <td><?php echo $row['Antwort2'];?></td>
	        <td><?php echo $row['Antwort3'];?></td>
	        <td><?php echo $row['Antwort4'];?></td>
	        <td><?php echo $row['Antwort5'];?></td>
	        <td><?php echo $row['Loesung1'];?></td>
	        <td><?php echo $row['Loesung2'];?></td>
	        <td><?php echo $row['Loesung3'];?></td>-->
	        <td>
	        	<?php 
	        		if ($row['Antwort1'] != '')
						echo "Antwort 1: " . $row['Antwort1']. '<br />';
					if ($row['Antwort2'] != '')
						echo "Antwort 2: " . $row['Antwort2']. '<br />';
					if ($row['Antwort3'] != '')
						echo "Antwort 3: " . $row['Antwort3']. '<br />';
					if ($row['Antwort4'] != '')
						echo "Antwort 4: " . $row['Antwort4']. '<br />';
					if ($row['Antwort5'] != '')
						echo "Antwort 5: " . $row['Antwort5']. '<br />';
				?>
	        </td>
	        <td>
	        	<?php switch ($row['Fragenart']) {
					case 'Multiple1':
						if ($row['Loesung1'] == 1)
							echo $row['Antwort1'];
						else if ($row['Loesung1'] == 2)
							echo $row['Antwort2'];
						else if ($row['Loesung1'] == 3)
							echo $row['Antwort3'];  
						else if ($row['Loesung1'] == 4)
							echo $row['Antwort4'];  
						else if ($row['Loesung1'] == 5)
							echo $row['Antwort5'];  
						break;
					case 'Multiple2':
						if ($row['Loesung1'] == 1)
							echo 'Lösung 1: ' . $row['Antwort1'] . '<br />';
						else if ($row['Loesung1'] == 2)
							echo 'Lösung 1: ' . $row['Antwort2'] . '<br />';
						else if ($row['Loesung1'] == 3)
							echo 'Lösung 1: ' . $row['Antwort3'] . '<br />';  
						else if ($row['Loesung1'] == 4)
							echo 'Lösung 1: ' . $row['Antwort4'] . '<br />';  
						else if ($row['Loesung1'] == 5)
							echo 'Lösung 1: ' . $row['Antwort5'] . '<br />';  
						
						if ($row['Loesung2'] == 1)
							echo 'Lösung 2: ' . $row['Antwort1'] . '<br />';
						else if ($row['Loesung2'] == 2)
							echo 'Lösung 2: ' . $row['Antwort2'] . '<br />';
						else if ($row['Loesung2'] ==3)
							echo 'Lösung 2: ' . $row['Antwort3'] . '<br />';  
						else if ($row['Loesung2'] == 4)
							echo 'Lösung 2: ' . $row['Antwort4'] . '<br />';  
						else if ($row['Loesung2'] == 5)
							echo 'Lösung 2: ' . $row['Antwort5'] . '<br />';
						break;
					case 'Multiple3':
						if ($row['Loesung1'] == 1)
							echo 'Lösung 1: ' . $row['Antwort1'] . '<br />';
						else if ($row['Loesung1'] == 2)
							echo 'Lösung 1: ' . $row['Antwort2'] . '<br />';
						else if ($row['Loesung1'] == 3)
							echo 'Lösung 1: ' . $row['Antwort3'] . '<br />';  
						else if ($row['Loesung1'] == 4)
							echo 'Lösung 1: ' . $row['Antwort4'] . '<br />';  
						else if ($row['Loesung1'] == 5)
							echo 'Lösung 1: ' . $row['Antwort5'] . '<br />';  
						
						if ($row['Loesung2'] == 1)
							echo 'Lösung 2: ' . $row['Antwort1'] . '<br />';
						else if ($row['Loesung2'] == 2)
							echo 'Lösung 2: ' . $row['Antwort2'] . '<br />';
						else if ($row['Loesung2'] == 3)
							echo 'Lösung 2: ' . $row['Antwort3'] . '<br />';  
						else if ($row['Loesung2'] ==4)
							echo 'Lösung 2: ' . $row['Antwort4'] . '<br />';  
						else if ($row['Loesung2'] == 5)
							echo 'Lösung 2: ' . $row['Antwort5'] . '<br />';
						
						if ($row['Loesung3'] == 1)
							echo 'Lösung 3: ' . $row['Antwort1'] . '<br />';
						else if ($row['Loesung3'] == 2)
							echo 'Lösung  3: ' . $row['Antwort2'] . '<br />';
						else if ($row['Loesung3'] == 3)
							echo 'Lösung  3: ' . $row['Antwort3'] . '<br />';  
						else if ($row['Loesung3'] == 4)
							echo 'Lösung  3: ' . $row['Antwort4'] . '<br />';  
						else if ($row['Loesung3'] == 5)
							echo 'Lösung  3: ' . $row['Antwort5'] . '<br />';
						break;
					default:
						
						break;
				} 
	    		
	    		//echo $row['Loesung1'];
	        	?>
	        </td>
	        <td><?php echo $row['Punkte'];?></td>
	        <td>
		        <?php $this->load->helper(array('form')); ?>
		    	<?php echo validation_errors(); ?>
				<?php echo form_open('fragen_controller/validate_view')?>
				<input type="input" name="fragenid" hidden="true" value=<?php echo $row['ID'];?>  />
	        	<input class="art-button" type='submit' name='submit' value='Ändern' > 	       
	        </td>
	 		</form>        
	    </tr>
		<?php endforeach; ?>
	</tbody>
</table>
<?php $this->load->helper(array('form')); ?>
<?php echo validation_errors(); ?>
<?php echo form_open('fragen_controller/create_view')?>
<input class="art-button" type='submit' name='submit' value='Neue Frage' > <br /> <br />
</form>

<!--    ######################################   -->
<div id="pager" class="pager">
	<form>
		<img src="<?php echo base_url();?>assets/tablesorter/addons/pager/icons/first.png" class="first"/>
		<img src="<?php echo base_url();?>assets/tablesorter/addons/pager/icons/prev.png" class="prev"/>
		<input type="text" class="pagedisplay" disabled="disabled"/>
		<img src="<?php echo base_url();?>assets/tablesorter/addons/pager/icons/next.png" class="next"/>
		<img src="<?php echo base_url();?>assets/tablesorter/addons/pager/icons/last.png" class="last"/>
		<select class="pagesize">
			<option selected="selected"  value="10">10</option>
			<option value="5">5</option>
			<option value="30">30</option>
			<option  value="40">40</option>
		</select>
	</form>
</div>	

<!--    ######################################   -->

<?php
$this->load->helper(array('form'));
echo validation_errors(); 
echo form_open('klausurenfragen_controller/set_klausurfragen');
echo "<input type='input' name='klausurenid' hidden='true' value='".$klausurenid."'/>";
echo "<table id='klausurenfragen'>
		<thead>
	    	<tr>
		      	<th class='sorter-false' >Fragenr. </th>
		      	<th class='sorter-false' >Fragen ID </th>
	    	</tr>
		</thead>
		<tbody>";
			$a = 1;
			foreach($klausurenfragen as $row):
	  echo "<tr>
				<td>".$a." </td>
				<td>";
				echo "<input type='input' name='fragenid[".$a."]' value='".$row['FragenID']."'/><br />";				
		   echo"</td>
			</tr>";
			$a++;
			endforeach;
			for($i = $a; $i <= $anzahlfragen; $i++):
	  echo "<tr>
				<td>".$i." </td>
				<td>";
				echo "<input type='input' name='fragenid[".$i."]' /><br />";				
		   echo"</td>
			</tr>";
			endfor; 
 echo "</tbody>
	</table>";


echo "<input class='art-button' type='submit' name='submit' value='Fragen Speichern' > <br /> <br />
	 </form>";

?>
<script>
$(document).ready(function() 
    { 
        $("#fragen").tablesorter({ 
        // pass the headers argument and assing a object 
 
        theme: 'green',
        widthFixed: true, 
        widgets: ['zebra','filter'] 
    })
    $("#fragen").tablesorterPager({container: $("#pager")});
    $("#klausurenfragen").tablesorter({ 
        // pass the headers argument and assing a object 
 
        theme: 'green',
        widthFixed: true, 
        widgets: ['zebra'] 
    })
    
    }
    
); 
</script>